﻿using DtoFw;
using DtoFw.Interface;
using DtoFw.Query;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SceneEvidenceAPISDK
{
    public class ApiDic : Base, IDic
    {
        /// <summary>
        /// 移除字典
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public BaseResult Delete(DeleteSingleDto query)
        {
            return HttpTools.Delete<BaseResult>(
                  query, base.GetApiRouter("Delete"));
        }
        /// <summary>
        /// 获取字典对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BaseGenericResult<DicDto> Get(long id)
        {
            return HttpTools.Get<BaseGenericResult<DicDto>>(
                base.GetApiRouter("Get", id.ToString()));
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public BaseResult Post(DicAddDto dto)
        {
            return HttpTools.Post<BaseResult>(
                dto, base.GetApiRouter("Post"));
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public BaseResult Put(DicUpdateDto dto)
        {
            return HttpTools.Put<BaseResult>(
                dto, base.GetApiRouter("Put"));
        }
        /// <summary>
        /// 获取字典树
        /// </summary>
        /// <returns></returns>
        public BaseGenericResult<List<DicDto>> Query()
        {
            return HttpTools.Get<BaseGenericResult<List<DicDto>>>(
                base.GetApiRouter("Query"));
        }
        /// <summary>
        /// 通过父节点获取子节点
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public BaseGenericResult<List<DicDto>> QueryToParentId(long parentId)
        {
            return HttpTools.Get<BaseGenericResult<List<DicDto>>>(
              base.GetApiRouter("QueryToParentId", parentId.ToString()));
        }
    }
}
